<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>登录</title>
<meta name="description" content="这是一个登录页面">
<meta name="keywords" content="index">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="apple-touch-icon-precomposed" href="static/i/app-icon72x72@2x.png">
<meta name="apple-mobile-web-app-title" content="Login" />
<link href="//cdn.bootcss.com/amazeui/2.7.2/css/amazeui.min.css" rel="stylesheet">
<link rel="stylesheet" href="../../static/css/app.css">

</head>

<body data-type="login" class="theme-black">
	<div class="am-g tpl-g">
		<div class="tpl-login">
			<div class="tpl-login-content">
				<div class="tpl-login-logo"></div>
				<form class="am-form tpl-form-line-form">
					<div class="am-form-group">
						<input type="text" class="tpl-form-input" id="user-name"
							placeholder="请输入账号">
					</div>
					<div class="am-form-group">
						<input type="password" class="tpl-form-input" id="user-pwd"
							placeholder="请输入密码">
					</div>
					<div class="am-form-group tpl-login-remember-me">
						<input id="remember-me" type="checkbox"> <label
							for="remember-me">记住密码</label>
					</div>
					<div class="am-form-group">
						<button type="button"  class="am-btn am-btn-primary  am-btn-block tpl-btn-bg-color-success  tpl-login-btn"
						onclick="login();">提交</button>
					</div>
				</form>
			</div>
		</div>
	</div>
</body>
<script src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
<script src="//cdn.bootcss.com/amazeui/2.7.2/js/amazeui.min.js"></script>
<script type="text/javascript" src="../../../webapp/static/js/jquery.tips.js"></script>

<script type="text/javascript">
	function login() {
	    if (checkLoginInfo()) {
	        var loginname = $("#user-name").val();
	        var password = $("#user-pwd").val();
	        $.ajax({
	            type: "POST",
	            url: 'userAction/login',
	            data: {loginId: loginname, pwd: password},
	            dataType: 'json',   //当这里指定为json的时候，获取到了数据后会自己解析的，只需要 返回值.字段名称 就能使用了
	            cache: false,
	            success: function (data) {
	                if (data.code == 1) {
	                    window.location.href = data.data.nextUrl;
	                } else {
	                    alert(data.msg);
	                    $("#user-name").focus();
	                }
	            }
	        });
	    }
	}
	

	function checkLoginInfo() {
		if ("" == $("#user-name").val()) {
			$("#user-name").tips({
				side : 3,
				msg : '用户名不得为空',
				bg : '#AE81FF',
				time : 3
			});
			$("#user-name").focus();
			return false;
		}
		if ($("#user-pwd").val() == "") {

			$("#user-pwd").tips({
				side : 2,
				msg : '密码不得为空',
				bg : '#AE81FF',
				time : 3
			});
			$("#user-pwd").focus();
			return false;
		}
		return true;
	}
</script>
</html>